/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.handlers.commands;

/**
 * This exception is raised by {@link XRENewCommandHandler} if the ID of XREObject to be created already exists.
 * <p>
 * Note the exception will only be propagated to {@link XREAggregateCommandHandler} and then processed by
 * {@link XRECommandErrorHandler}. It extends {@link XREObjectCommandHandlerException}.
 * <p>
 * <b>Thread Safety:</b> This class is not thread safe as its base class is not thread safe.
 *
 * @author liuliquan, 7realm
 * @version 1.0
 */
public class DuplicateXREObjectIdException extends XREObjectCommandHandlerException {
    /** Serial version UID. */
    private static final long serialVersionUID = 8561071701672406333L;
    /**
     * The duplicate ID of XREObject which already exists.
     * <p>
     * Initialized in constructor and will not change after. Can be any value. It has a getter.
     */
    private final int duplicateId;

    /**
     * Creates a new instance of {@link DuplicateXREObjectIdException} with given error message and the duplicate ID of
     * XREObject which already exists.
     *
     * @param message the error message
     * @param duplicateId the duplicate ID of XREObject which already exists
     */
    public DuplicateXREObjectIdException(String message, int duplicateId) {
        super(message);
        this.duplicateId = duplicateId;
    }

    /**
     * Creates a new instance of {@link DuplicateXREObjectIdException} with given error message, the cause and the
     * duplicate ID of XREObject which already exists.
     *
     * @param message the error message
     * @param cause the cause of the exception
     * @param duplicateId the duplicate ID of XREObject which already exists
     */
    public DuplicateXREObjectIdException(String message, Throwable cause, int duplicateId) {
        super(message, cause);
        this.duplicateId = duplicateId;
    }

    /**
     * Gets the duplicate ID of XREObject which already exists.
     *
     * @return the duplicate ID of XREObject which already exists
     */
    public int getDuplicateId() {
        return duplicateId;
    }
}